import 'package:flutter/material.dart';
import 'package:three/pages/detail_page.dart';

class HomePage extends StatelessWidget{
  const HomePage({super.key});
  @override
  Widget build(BuildContext context) {
    return 
      Scaffold(
        appBar: AppBar(
          title: const Text('HomePage'),
        ),
       body: const HomePageBody(),
      );
  }
}
class HomePageBody extends StatelessWidget{
  const HomePageBody({super.key});
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          const Text('HomePage'),
          ElevatedButton(
            onPressed: (){
              //跳转详情页
              Navigator.push(context, MaterialPageRoute(builder: (context)=>const DetailPage()));
            },
            child: const Text('跳转详情页-写法1'),
          ),
          ElevatedButton(
            onPressed: (){
              //跳转详情页-写法2
              Navigator.pushNamed(context, '/detail');
            },
            child: const Text('跳转详情页-写法2'),
          ),
        ],
      ),
      
    );
  }
}
